mui.init();//初始化mui

$(document).ready(function(){
	var url = "/index/index/";
	/*底部跳转部分*/
	$('.mui-tab-item').on('tap',function(){
		var index = $(this).index();

		if(index == 0){//进入首页
			window.location.href = url+'index';
		}else if(index == 1){//进入积分榜
			window.location.href = url+'rankings';
		}else if(index == 2){//进入平台使用
			window.location.href = url+'platform';
		}else if(index == 3){//进入个人中心
			window.location.href = url+'core';
		}
	});

});
//写cookies
function setCookie(c_name, value, expiredays)
{
 　　　　var exdate=new Date();
　　　　exdate.setDate(exdate.getDate() + expiredays);
　　　　document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

//读取cookies
function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;
};
//删除cookies
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null)
        document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
window.onload = function(){
	//头像背景颜色设置
	$.each($('.head-portrait'),function(i,v){
		var color = $(v).attr('data-color');
		if(color){
			$(v).css('background',color);
		}else{
			console.log('当前头像没有设置颜色');
		}
	})
}
